#!/bin/bash
MONGO_LOG=/tmp/mongo.log
mongo 127.0.0.1:27017/admin > ${MONGO_LOG}  <<EOF

db.system.users.remove({})
use admin
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"admin"}]})
use com-foxit-storage
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"com-foxit-storage"}]})
db.appId.save({"_id" : ObjectId("52de206cbc8f034747de6b50"),"_class" : "com.foxit.userspace.core.entity.AppId","app_id" : "JTvonpLFbtEA","app_name" : "formpublish","delFlag" : 0})
db.appId.save({"_id" : ObjectId("52de206cbc8f034747de6b23"),"_class" : "com.foxit.userspace.core.entity.AppId","app_id" : "WcHcviXeBTBx","app_name" : "webreader","delFlag" : 0})
db.appId.save({ "_id" : ObjectId("52de206cbc8f034747de6b21"), "_class" : "com.foxit.userspace.core.entity.AppId", "app_id" : "bmAPnhA0PR99", "app_name" : "cloudreading", "delFlag" : 0 })
use foxit-reading
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"foxit-reading"}]})
use com-foxit-schedule
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"com-foxit-schedule"}]})
use com-foxit-session
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"com-foxit-session"}]})
db.createUser({"user": "foxitwebreader", "pwd": "PP9dqMcLYCcJdqwO6akNYkTjUORPQE","roles" : [ { role: "dbOwner",db:"com-foxit-session"}]})
use com-foxit-sso
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"com-foxit-sso"}]})
use com-foxit-user-center
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"com-foxit-user-center"}]})
db.user.save({ "_id" : ObjectId("53f2cf9a0cf261f21c11bbb2"), "_class" : "com.foxit.user.entity.User", "email" : "test@fp.com", "password" : "cb04f30917263fba79557927362fc7f8d5bc8abb", "locked" : 0, "role" : 0, "status" : 0, "delFlag" : 0, "createTime" : ISODate("2014-08-19T04:16:26.926Z"), "updateTime" : ISODate("2014-08-19T04:40:34.986Z"), "activeTimestamp" : NumberLong("1408421786926"), "resetPasswordTimestamp" : NumberLong(0) })
db.user.save({ "_id" : ObjectId("53f2c1df0cf261f21c11aa90"), "_class" : "com.foxit.user.entity.User", "email" : "demo@fp.com", "password" : "cb04f30917263fba79557927362fc7f8d5bc8abb", "locked" : 0, "role" : 0, "status" : 0, "delFlag" : 0, "createTime" : ISODate("2014-08-19T03:17:51.385Z"), "updateTime" : ISODate("2014-08-19T03:17:51.385Z"), "activeTimestamp" : NumberLong("1408418271385")})
db.user.save({ "_id" : ObjectId("53f2cf9a0cf261f21c11aaa2"), "_class" : "com.foxit.user.entity.User", "email" : "admin@fp.com", "password" : "cb04f30917263fba79557927362fc7f8d5bc8abb", "locked" : 0, "role" : 0, "status" : 0, "delFlag" : 0, "createTime" : ISODate("2014-08-19T04:16:26.926Z"), "updateTime" : ISODate("2014-08-19T04:40:34.986Z"), "activeTimestamp" : NumberLong("1408421786926"), "resetPasswordTimestamp" : NumberLong(0) })
db.user.save({ "_id" : ObjectId("53f2cf9a0cf261f21c11aaa3"), "_class" : "com.foxit.user.entity.User", "email" : "admin@ucx.local", "password" : "cb04f30917263fba79557927362fc7f8d5bc8abb", "locked" : 0, "role" : 0, "status" : 0, "delFlag" : 0, "createTime" : ISODate("2014-08-19T04:16:26.926Z"), "updateTime" : ISODate("2014-08-19T04:40:34.986Z"), "activeTimestamp" : NumberLong("1408421786926"), "resetPasswordTimestamp" : NumberLong(0) })
db.user.save({ "_id" : ObjectId("53f2cf9a0cf261f21c11aaa4"), "_class" : "com.foxit.user.entity.User", "email" : "demo@ucx.local", "password" : "cb04f30917263fba79557927362fc7f8d5bc8abb", "locked" : 0, "role" : 0, "status" : 0, "delFlag" : 0, "createTime" : ISODate("2014-08-19T04:16:26.926Z"), "updateTime" : ISODate("2014-08-19T04:40:34.986Z"), "activeTimestamp" : NumberLong("1408421786926"), "resetPasswordTimestamp" : NumberLong(0) })
db.user.save({ "_id" : ObjectId("53f2cf9a0cf261f21c11aaa5"), "_class" : "com.foxit.user.entity.User", "email" : "foxit@ucx.local", "password" : "cb04f30917263fba79557927362fc7f8d5bc8abb", "locked" : 0, "role" : 0, "status" : 0, "delFlag" : 0, "createTime" : ISODate("2014-08-19T04:16:26.926Z"), "updateTime" : ISODate("2014-08-19T04:40:34.986Z"), "activeTimestamp" : NumberLong("1408421786926"), "resetPasswordTimestamp" : NumberLong(0) })
use foxit-filesystem
db.createUser({"user": "mongo", "pwd": "mongo","roles" : [ { role: "dbOwner",db:"foxit-filesystem"}]})
use com-foxit-plugin
db.addUser("mongo","mongo")
use com-foxit-apimgt
db.addUser("mongo","mongo")
EOF

echo "MongoDB initialized, log file is at ${MONGO_LOG}."
touch /tmp/MONGOINITED
